home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Applications / Tcl-Tk 8.0 / Pre-installed version / tcl8.0 / unix / tclAppInit.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-08-15  |  3.5 KB  |  137 lines  |  [TEXT/CWIE]

  1. /* 
  2.  * tclAppInit.c --
  3.  *
  4.  *    Provides a default version of the main program and Tcl_AppInit
  5.  *    procedure for Tcl applications (without Tk).
  6.  *
  7.  * Copyright (c) 1993 The Regents of the University of California.
  8.  * Copyright (c) 1994-1997 Sun Microsystems, Inc.
  9.  *
  10.  * See the file "license.terms" for information on usage and redistribution
  11.  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  12.  *
  13.  * SCCS: @(#) tclAppInit.c 1.20 97/03/24 14:29:43
  14.  */
  15.  
  16. #ifdef TCL_XT_TEST
  17. #include <X11/Intrinsic.h>
  18. #endif
  19.  
  20. #include "tcl.h"
  21.  
  22. /*
  23.  * The following variable is a special hack that is needed in order for
  24.  * Sun shared libraries to be used for Tcl.
  25.  */
  26.  
  27. extern int matherr();
  28. int *tclDummyMathPtr = (int *) matherr;
  29.  
  30.  
  31. #ifdef TCL_TEST
  32. EXTERN int        TclObjTest_Init _ANSI_ARGS_((Tcl_Interp *interp));
  33. EXTERN int        Tcltest_Init _ANSI_ARGS_((Tcl_Interp *interp));
  34. #endif /* TCL_TEST */
  35. #ifdef TCL_XT_TEST
  36. EXTERN int        Tclxttest_Init _ANSI_ARGS_((Tcl_Interp *interp));
  37. #endif
  38.  
  39. /*
  40.  *----------------------------------------------------------------------
  41.  *
  42.  * main --
  43.  *
  44.  *    This is the main program for the application.
  45.  *
  46.  * Results:
  47.  *    None: Tcl_Main never returns here, so this procedure never
  48.  *    returns either.
  49.  *
  50.  * Side effects:
  51.  *    Whatever the application does.
  52.  *
  53.  *----------------------------------------------------------------------
  54.  */
  55.  
  56. int
  57. main(argc, argv)
  58.     int argc;            /* Number of command-line arguments. */
  59.     char **argv;        /* Values of command-line arguments. */
  60. {
  61. #ifdef TCL_XT_TEST
  62.     XtToolkitInitialize();
  63. #endif
  64.     Tcl_Main(argc, argv, Tcl_AppInit);
  65.     return 0;            /* Needed only to prevent compiler warning. */
  66. }
  67.  
  68. /*
  69.  *----------------------------------------------------------------------
  70.  *
  71.  * Tcl_AppInit --
  72.  *
  73.  *    This procedure performs application-specific initialization.
  74.  *    Most applications, especially those that incorporate additional
  75.  *    packages, will have their own version of this procedure.
  76.  *
  77.  * Results:
  78.  *    Returns a standard Tcl completion code, and leaves an error
  79.  *    message in interp->result if an error occurs.
  80.  *
  81.  * Side effects:
  82.  *    Depends on the startup script.
  83.  *
  84.  *----------------------------------------------------------------------
  85.  */
  86.  
  87. int
  88. Tcl_AppInit(interp)
  89.     Tcl_Interp *interp;        /* Interpreter for application. */
  90. {
  91.     if (Tcl_Init(interp) == TCL_ERROR) {
  92.     return TCL_ERROR;
  93.     }
  94.  
  95. #ifdef TCL_TEST
  96. #ifdef TCL_XT_TEST
  97.      if (Tclxttest_Init(interp) == TCL_ERROR) {
  98.      return TCL_ERROR;
  99.      }
  100. #endif
  101.     if (Tcltest_Init(interp) == TCL_ERROR) {
  102.     return TCL_ERROR;
  103.     }
  104.     Tcl_StaticPackage(interp, "Tcltest", Tcltest_Init,
  105.             (Tcl_PackageInitProc *) NULL);
  106.     if (TclObjTest_Init(interp) == TCL_ERROR) {
  107.     return TCL_ERROR;
  108.     }
  109. #endif /* TCL_TEST */
  110.  
  111.     /*
  112.      * Call the init procedures for included packages.  Each call should
  113.      * look like this:
  114.      *
  115.      * if (Mod_Init(interp) == TCL_ERROR) {
  116.      *     return TCL_ERROR;
  117.      * }
  118.      *
  119.      * where "Mod" is the name of the module.
  120.      */
  121.  
  122.     /*
  123.      * Call Tcl_CreateCommand for application-specific commands, if
  124.      * they weren't already created by the init procedures called above.
  125.      */
  126.  
  127.     /*
  128.      * Specify a user-specific startup file to invoke if the application
  129.      * is run interactively.  Typically the startup file is "~/.apprc"
  130.      * where "app" is the name of the application.  If this line is deleted
  131.      * then no user-specific startup file will be run under any conditions.
  132.      */
  133.  
  134.     Tcl_SetVar(interp, "tcl_rcFileName", "~/.tclshrc", TCL_GLOBAL_ONLY);
  135.     return TCL_OK;
  136. }
  137.